﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using DataAccess;
using BusinessLogic;

namespace ATM_System_Mock1_G2
{
    public partial class ViewHistory3 : System.Web.UI.Page
    {
        ConnectDB cn = new ConnectDB();
        CustomerBL cusBL = new CustomerBL();
        CardEntites carE = new CardEntites();
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((int)Session["ViewHistory"] == 1)
            {
                Show_ViewHistory_OneYear();
            }
            else if ((int)Session["ViewHistory"] == 2)
            {
                Show_ViewHistory_TwoYear();
            }
            else if ((int)Session["ViewHistory"] == 3)
            {
                Show_ViewHistory_OneWeek();
            }
            else if ((int)Session["ViewHistory"] == 4)
            {
                Show_ViewHistory_OneMonth();
            }
            else if ((int)Session["ViewHistory"] == 5)
            {
                Show_ViewHistory_FourMonth();
            }
            else
            {
                Show_ViewHistory_SixMonth();
            }

        }
        public void Show_ViewHistory_OneYear()
        {

            string cardNo = Session["CardNo"].ToString();
            GV_History.DataSource = cusBL.ViewHistory_OneYear(cardNo);
            GV_History.DataBind();
            
        }
        public void Show_ViewHistory_TwoYear()
        {

            string cardNo = Session["CardNo"].ToString();
            GV_History.DataSource = cusBL.ViewHistory_TwoYear(cardNo);
            GV_History.DataBind();
           
        }
        public void Show_ViewHistory_OneWeek()
        {

            string cardNo = Session["CardNo"].ToString();
            GV_History.DataSource = cusBL.ViewHistory_OneWeek(cardNo);
            GV_History.DataBind();
        }
        public void Show_ViewHistory_OneMonth()
        {

            string cardNo = Session["CardNo"].ToString();
            GV_History.DataSource = cusBL.ViewHistory_OneMonth(cardNo);
            GV_History.DataBind();
           
        }
        public void Show_ViewHistory_FourMonth()
        {

            string cardNo = Session["CardNo"].ToString();
            GV_History.DataSource = cusBL.ViewHistory_FourMonth(cardNo);
            GV_History.DataBind();
            
        }
        public void Show_ViewHistory_SixMonth()
        {

            string cardNo = Session["CardNo"].ToString();
            GV_History.DataSource = cusBL.ViewHistory_SixMonth(cardNo);
            GV_History.DataBind();
           
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Response.Redirect("ViewHistory1.aspx");
        }

        protected void Button11_Click(object sender, EventArgs e)
        {
            Response.Redirect("Home.aspx");
        }

        protected void GV_History_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            int NewPage;
            NewPage = e.NewPageIndex;
            if (NewPage < 0 || NewPage >= GV_History.PageCount)
            {
                e.Cancel = true;
            }
            else
            {
                GV_History.PageIndex = NewPage;
                GV_History.DataBind();
            }
        }

        protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                GV_History.PageIndex += 1;
                GV_History.DataBind();
            }
            catch
            { }
        }

        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                GV_History.PageIndex -= 1;
                GV_History.DataBind();
            }
            catch
            { }
        }

        protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("ViewHistory2.aspx");
        }


    }
}